<?php
  require('includes/application_top.php');
 
  $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
  if (tep_not_null($action)) {
    switch ($action) {
        case 'save':
            $id = $_POST['id'];           
            $api = $_POST['api'];
            //$fb_enable = $_POST['fb_enable'];
            if($id){
                tep_db_query("UPDATE ushop_fb_config SET api=$api WHERE id=$id");                
            }
            tep_redirect(tep_href_link('fb_config.php'));
        break;
        
        case 'fb_enable':
            tep_db_query("update ushop_fb_config set fb_enable = '1' where id = '" . (int)$HTTP_GET_VARS['id'] . "'");
            tep_redirect(tep_href_link('fb_config.php'));
        break;
        
        case 'fb_disable':
            tep_db_query("update ushop_fb_config set fb_enable = '0' where id = '" . (int)$HTTP_GET_VARS['id'] . "'");
            tep_redirect(tep_href_link('fb_config.php'));
        break;
    }
  } 
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>

</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<div id="spiffycalendar" class="text"></div>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
    <td width="<?php echo BOX_WIDTH; ?>" valign="top">
    <table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
    </table></td>
<!-- body_text //-->
    <td valign="top">

<form name="fbconfig" action="fb_config.php?action=save" method="post">
<table cellpadding="0" cellspacing="0" border="0" width="400px">
<?php
    $fbconfig_query = tep_db_query("select * from ushop_fb_config");
    while ($fbconfig = tep_db_fetch_array($fbconfig_query)) {
        
        if($fbconfig['fb_enable']==0){
            $fb_enable = '<a href="' . tep_href_link('fb_config.php', 'id=' . $fbconfig['id'] . '&action=fb_enable') . '">Chưa kích hoạt</a>';
        }else{
            $fb_enable = '<a href="' . tep_href_link('fb_config.php', 'id=' . $fbconfig['id'] . '&action=fb_disable') . '">Đã kích hoạt</a>';
        }
        
        echo tep_draw_hidden_field('id',$fbconfig['id']);
        echo '<tr><td>Kích hoạt <b>ushop</b> on facebook: </td><td>'.$fb_enable.'</td></tr>';
        echo '<tr><td>API: </td><td>'.tep_draw_input_field('api',$fbconfig['api']).'</td></tr>';        
        echo '<tr><td></td><td><br />'.tep_image_submit('button_update.gif', IMAGE_UPDATE).'</td></tr>';
        
     }
?>
</table>
</form>

    </td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
